import adminRequest from "@/utils/http/adminRequest.js";

// 登录接口
export const loginAPI = ({username, password}) => {
    return adminRequest.post('/admin/login', {username, password})
}

// 获取管理员信息接口（本人）
export const adminInfoAPI = () => {
    return adminRequest.get('/admin/admininfo')
}

// 更新用户信息接口
export const updateAdminInfoAPI = ({id, name, username, phone, idNumber}) => {
    return adminRequest.put('/admin/admininfo', {id, name, username, phone, idNumber})
}

// 更新密码接口
export const updatePasswordAPI = ({oldPwd, newPwd, rePwd}) => {
    return adminRequest.patch('/admin/password', {oldPwd, newPwd, rePwd})
}

// 更新头像接口
export const updateAvatarAPI = (avatar) => {
    return adminRequest.patch('/admin/avatar', {avatar})
}

// 获取管理员列表
export const adminListAPI = (params) => {
    return adminRequest.get('/admin/page', {
        params
    })
}

// 获取管理员详细信息接口
export const adminDetailAPI = (id) => {
    return adminRequest.get(`/admin/detail/${id}`)
}

// 切换管理员状态
export const adminStateChangeAPI = (id) => {
    return adminRequest.patch('/admin/state', {id})
}

// 更新管理员信息
export const adminUpdateAPI = (adminInfo) => {
    return adminRequest.put('/admin', adminInfo)
}

// 添加管理员信息
export const adminAddAPI = (adminInfo) => {
    return adminRequest.post('/admin', adminInfo)
}
